package com.app.jwt.controller;

import com.app.jwt.util.JWTUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class JwtController {
    @RequestMapping("/api/login")
    public Map findById(String name, String password) {
        System.out.println(name);
        System.out.println(password);
        // 生成令牌
        Map<String, Object> payload = new HashMap();
        payload.put("id", "123");
        payload.put("name", name);
        String token = JWTUtils.getToken(payload);
        System.out.println(token);
        return payload;
    }

    @RequestMapping(value = "/api/query")
    public Map query() {
        Map<String, Object> payload = new HashMap();
        payload.put("id", "123");
        payload.put("id2", "1234");
        payload.put("id3", "12345");
        System.out.println(payload);
        return payload;
    }
}
